package com.job.springSea.work0716;

/**
 * @author 于春海
 * @version 1.0
 * @since 2022-07-16 19:24:52
 */
public class CharCount {
    Character code;
    Integer count=1;
    public void CountNumber(String str){
        char[] ch=new char[str.length()];
        ch=str.toCharArray();
        char[] ch1=new char[str.length()];
        int[] number=new int[str.length()];
        int j=0;
        for (int i = 0; i <str.length() ; i++) {
            if(Character.isUpperCase(ch[i]))   {
                ch1[j]=ch[i];
                for (int k = i+1; k < str.length(); k++) {
                        if(ch1[j]==ch[k]) {
                            count++;
                            ch[k]='0';
                        }
                }
                number[j]=count;
                count=1;
                j++;
            }
        }
        for (int i = 0; i <j-1 ; i++) {
            for (int k = i+1; k <j ; k++) {
                if(number[i]<number[k]){
                    int temp;
                    temp=number[i];
                    number[i]=number[k];
                    number[k]=temp;
                    code=ch1[i];
                    ch1[i]=ch1[k];
                    ch1[k]=code;
                }
            }
        }
        for (int i = 0; i <j ; i++) {
            System.out.print(ch1[i]+",");
            System.out.println(number[i]);
        }
    }
}